package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Open_subject;
import com.example.Laboratory.Service.Open_subjectService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@RestController
@Api(value = "Open_subject", description = "开放课题")
@RequestMapping(value = "/open_subject")
@CrossOrigin
public class Open_subjectController {

    @Autowired
    Open_subjectService open_subjectService;

    @ApiOperation(value = "添加开放课题", notes = "添加开放课题")
    @RequestMapping(value = "/addOpen_subject", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addOpen_subject (Open_subject t) throws IOException {
        return ResultCode.SUCCESS.result(open_subjectService.addOpen_subject(t));
    }

    @ApiOperation(value = "删除开放课题", notes = "删除开放课题")
    @RequestMapping(value = "/deleteOpen_subject", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteOpen_subject (@RequestParam int open_subject_id) throws IOException {
        return ResultCode.SUCCESS.result(open_subjectService.deleteOpen_subject(open_subject_id));
    }

    @ApiOperation(value = "查找开放课题", notes = "查找开放课题")
    @RequestMapping(value = "/researchOpen_subject", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectOpen_subject ( ) throws IOException {
        return ResultCode.SUCCESS.result(open_subjectService.selectOpen_subject());
    }

    @ApiOperation(value = "修改开放课题", notes = "修改开放课题")
    @RequestMapping(value = "/reviseOpen_subject", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateOpen_subject (Open_subject i) throws IOException {
        return ResultCode.SUCCESS.result(open_subjectService.updateOpen_subject(i));
    }
}